// ITI1120 (Fall 2012), Lab 3, Exercise 1 // Name: , Student #: 1234567 // Program Description: import java.util.Scanner ; class Lab3Ex1V2 { /** * Check a person's age in order to accept a transaction. */ public static void main (String[] args) { // KEYBOARD INPUT CONFIGURATION // You can safely remove these lines if you use // the ITI1120 class for data entry Scanner input = new Scanner(System.in); // VARIABLE DECLARATIONS int age; // The person's age boolean accepted; // TRUE if the transaction is accepted // PRINT ID INFO System.out.println(); System.out.println("ITI1120 (F-2012), Lab 3, Exercise 1"); System.out.println("Name: John Doe, Student #: 1234567"); System.out.println("TA: YourTA"); System.out.println(); // READ INPUT System.out.print("What is the person's age"); age = input.nextInt(); // CALL VERIFICATION METHOD accepted = verifyAge(age); // SHOW RESULT if(accepted) { System.out.println("Transaction accepted"); } else { System.out.println("Transaction denied"); } } /** * Description: Return TRUE if age is * between 18 and 55 inclusive. * Parameters (DATA): age - person's age */ public static boolean verifyAge(int age) { // DECLARE RETURN VARIABLE boolean accepted; // TRUE if age is within limits. // CALCULATE if((age >= 18) && (age <= 55)) { accepted = true; } else { accepted = false; } // RETURN THE RESULT return(accepted); } }